package com.mccree.nio;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.channels.FileChannel;

public class NIOFileChannel04 {
    public static void main(String[] args) throws IOException {
        //创建相关流
        FileInputStream fileInputStream = new FileInputStream("D:\\临时\\netty文件\\1.jpg");
        FileOutputStream fileOutputStream = new FileOutputStream("D:\\临时\\netty文件\\2.jpg");

        //获取相关管道
        FileChannel sourceChannel = fileInputStream.getChannel();
        FileChannel destChannel = fileOutputStream.getChannel();

        //使用transferForm完成拷贝
        destChannel.transferFrom(sourceChannel,0,sourceChannel.size());

        //关闭资源
        fileOutputStream.close();
        fileInputStream.close();

    }
}
